#!/usr/bin/env python

import pandas as pd
import MySQLdb
from sqlalchemy import create_engine

conn = create_engine("mysql+mysqldb://python:123456@localhost:3306/1810?charset=utf8")
# headers = [1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21]
s = 'CREATEDATE, LOCALDATE (BEIJING), SITE, WSINS (MPS), WS2M (MPS), WS2A (MPS), WS2X (MPS), WS10M (MPS), WS10A (MPS), WS10X (MPS), WDINS, WD2M, WD2A, WD2X, WD10M, WD10A, WD10X, GUST_SPEED (MPS), GUST_DIR, WDVAR, CW2A (MPS), HW2A (MPS), STATUS, MSGDATA' 
headers = s.split(',').extend(['A','B','C','D'])
df = pd.read_csv("./WIND_MPS_16_31.his",header=None,skiprows=2,names=headers)
print(df)
df.to_sql('wind',conn,index=False)
conn.dispose()
